import React from 'react'
//引入蚂蚁金服导航栏组件
import { NavBar, Icon } from 'antd-mobile';
import { request as axios } from '../../utils/request'
import { connect } from 'react-redux'

class Index extends React.Component {
    componentDidMount() {
        //1.获取城市列表
        axios.get('/area/city?level=1').then(res => {
            console.table(res.data.body);
        })
    }
    render() {
        return <div>
            {/* 1.导航栏 */}
            <NavBar
                mode="light"
                icon={<Icon type="left" />}
                onLeftClick={() => console.log('onLeftClick')}
            >城市列表
            </NavBar>
            <h1>{this.props.cityName} </h1>
        </div>
    }
}
//映射对象
const mapStateToProps = (state) => {
    return {
        cityName: state.cityReducer.cityName
    }
}
//映射函数

export default connect(mapStateToProps, null)(Index)